/*
 * sys_event.h
 *
 * realize system event function.
 *
 * Copyright (C) 2024 Sinh Micro, Inc.
 * Subject to the GNU Public License, version 2.
 *
 * Author: lixiang<lixiang@sinhmicro.com>
 * 
 * Encoding format: GB2312
 * Version: v1.2.2
 * Date: 2024-11-05
 */

#include "hal/inc/types.h"
#ifndef _EVENT_H_
#define _EVENT_H_

#define EVENT_STATE_NOP                 (0)
#define EVENT_STATE_HEATER_PLUGIN       (1 << 0)
#define EVENT_STATE_HEATER_PLUGOUT      (1 << 1)
#define EVENT_STATE_HEATER_PLUG_UNLOCK  (1 << 2)
#define EVENT_STATE_HEATER_PLUG_LOCK    (1 << 3) 
#define EVENT_STATE_MIC_PRESSED         (1 << 4)
#define EVENT_STATE_MIC_RELEASED        (1 << 5)

#define EVENT_STATE_HEAT_TIMEOUT        (1 << 6)
#define EVENT_STATE_HEAT_DRY_BURNING    (1 << 7)
#define EVENT_STATE_HEAT_OC             (1 << 8)
#define EVENT_STATE_HEAT_LOW_BAT        (1 << 9)
#define EVENT_STATE_HEAT_OPEN_CIRCULT   (1 << 10)

#define EVENT_STATE_PM_SLEEP            (1 << 11)
#define EVENT_STATE_LOCK                (1 << 12)
#define EVENT_STATE_UNLOCK              (1 << 13)

#define EVENT_STATE_HEATER_PLUG         (EVENT_STATE_HEATER_PLUGIN      | \
                                         EVENT_STATE_HEATER_PLUGOUT)

#define EVENT_STATE_QUIT_HEATING        (EVENT_STATE_MIC_RELEASED       | \
                                         EVENT_STATE_HEAT_TIMEOUT       | \
                                         EVENT_STATE_HEAT_DRY_BURNING   | \
                                         EVENT_STATE_HEAT_LOW_BAT       | \
                                         EVENT_STATE_HEAT_OC            | \
                                         EVENT_STATE_HEAT_OPEN_CIRCULT)
                                         
bool sys_event_test_and_clr_mask(uint16_t event_mask);
void sys_event_handle_100ms(void);

extern uint16_t event_state_mask;

#endif